package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class POSIDFactory extends AbstractTokenVisitorFactory {

	private static POSIDFactory INSTANCE;
	
	private POSIBILIDADES3Factory posibilidades3Factory;
	private POSPFactory pospFactory;

	
	public static POSIDFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new POSIDFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			posibilidades3Factory = POSIBILIDADES3Factory.getInstance();
			pospFactory = POSPFactory.getInstance();
		}
	};
	
	private POSIDFactory() throws Exception {

	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return posibilidades3Factory.makeChainedVisitor(pospFactory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return posibilidades3Factory.makeChainedVisitor(pospFactory.makeVisitor());
	}
	
	
}
